package com.elock.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.elock.base.core.entity.BaseEntity;

/**
 * Entity - 任务明细信息
 * @author 仁德
 */
@Entity
@Table(name = "terminal_task_item")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "terminal_task_item_sequence")
public class TerminalTaskItem extends BaseEntity {

	private static final long serialVersionUID = 1386745660360951034L;

	/** 任务单 */
	private TerminalTask terminalTask;

	/** 任务单流水号 */
	private String taskSn;

	/** 鹤位 */
	private Integer position;

	/** 车牌号 */
	private String plateNum;

	/** 舱位 */
	private Integer berth;

	/** 出发时间 */
	private Date startTime;

	/** 预计到达时间 */
	private Date endTime;

	/** 配送时长 */
	private String duration;

	/** 容量 */
	private BigDecimal volume;

	/** 品名 */
	private String goods;

	/** 数量 */
	private BigDecimal quantity;

	/** 卸油机构 */
	private SaleOrg toSaleOrg;

	/** 备注 */
	private String memo;

	/**  
	 * 获取terminalTask  
	 * @return terminalTask terminalTask  
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	public TerminalTask getTerminalTask() {
		return terminalTask;
	}

	/**  
	 * 设置terminalTask  
	 * @param terminalTask terminalTask  
	 */
	public void setTerminalTask(TerminalTask terminalTask) {
		this.terminalTask = terminalTask;
	}

	/**  
	 * 获取taskSn  
	 * @return taskSn taskSn  
	 */
	@Column(updatable = false)
	public String getTaskSn() {
		return taskSn;
	}

	/**  
	 * 设置taskSn  
	 * @param taskSn taskSn  
	 */
	public void setTaskSn(String taskSn) {
		this.taskSn = taskSn;
	}

	/**  
	 * 获取position  
	 * @return position position  
	 */
	public Integer getPosition() {
		return position;
	}

	/**  
	 * 设置position  
	 * @param position position  
	 */
	public void setPosition(Integer position) {
		this.position = position;
	}

	/**  
	 * 获取plateNum  
	 * @return plateNum plateNum  
	 */
	public String getPlateNum() {
		return plateNum;
	}

	/**  
	 * 设置plateNum  
	 * @param plateNum plateNum  
	 */
	public void setPlateNum(String plateNum) {
		this.plateNum = plateNum;
	}

	/**  
	 * 获取berth  
	 * @return berth berth  
	 */
	public Integer getBerth() {
		return berth;
	}

	/**  
	 * 设置berth  
	 * @param berth berth  
	 */
	public void setBerth(Integer berth) {
		this.berth = berth;
	}

	/**  
	 * 获取startTime  
	 * @return startTime startTime  
	 */
	public Date getStartTime() {
		return startTime;
	}

	/**  
	 * 设置startTime  
	 * @param startTime startTime  
	 */
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	/**  
	 * 获取endTime  
	 * @return endTime endTime  
	 */
	public Date getEndTime() {
		return endTime;
	}

	/**  
	 * 设置endTime  
	 * @param endTime endTime  
	 */
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	/**  
	 * 获取duration  
	 * @return duration duration  
	 */
	public String getDuration() {
		return duration;
	}

	/**  
	 * 设置duration  
	 * @param duration duration  
	 */
	public void setDuration(String duration) {
		this.duration = duration;
	}

	/**  
	 * 获取volume  
	 * @return volume volume  
	 */
	@Column(nullable = false, precision = 21, scale = 6)
	public BigDecimal getVolume() {
		return volume;
	}

	/**  
	 * 设置volume  
	 * @param volume volume  
	 */
	public void setVolume(BigDecimal volume) {
		this.volume = volume;
	}

	/**  
	 * 获取goods  
	 * @return goods goods  
	 */
	public String getGoods() {
		return goods;
	}

	/**  
	 * 设置goods  
	 * @param goods goods  
	 */
	public void setGoods(String goods) {
		this.goods = goods;
	}

	/**  
	 * 获取quantity  
	 * @return quantity quantity  
	 */
	@Column(nullable = false, precision = 21, scale = 6)
	public BigDecimal getQuantity() {
		return quantity;
	}

	/**  
	 * 设置quantity  
	 * @param quantity quantity  
	 */
	public void setQuantity(BigDecimal quantity) {
		this.quantity = quantity;
	}

	/**  
	 * 获取toSaleOrg  
	 * @return toSaleOrg toSaleOrg  
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	public SaleOrg getToSaleOrg() {
		return toSaleOrg;
	}

	/**  
	 * 设置toSaleOrg  
	 * @param toSaleOrg toSaleOrg  
	 */
	public void setToSaleOrg(SaleOrg toSaleOrg) {
		this.toSaleOrg = toSaleOrg;
	}

	/**  
	 * 获取memo  
	 * @return memo memo  
	 */
	public String getMemo() {
		return memo;
	}

	/**  
	 * 设置memo  
	 * @param memo memo  
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 * 持久化前处理
	 */
	@PrePersist
	public void prePersist() {
		if (getTaskSn() == null) {
			setTaskSn(getTerminalTask().getSn());
		}
	}
}
